<template>
	<el-container>
		<el-header style="height: auto;" >
			<el-card style="width: 100%; height: auto;" shadow="hover">
				<div>
					<!-- <sc-search :config="config"
					         @search="onSearch"
					/> -->
					<searchCmp />
				</div>
			</el-card>
		</el-header>
		<el-header>
			<div class="left-panel">
				<el-button type="primary" icon="el-icon-plus" ></el-button>
				<el-button type="primary" plain >分配角色</el-button>
				<el-button type="primary" plain >密码重置</el-button>
			</div>
			<div class="right-panel">
				<el-button  type="primary" plain icon="el-icon-share" circle />
				<el-button  type="primary" plain icon="sc-icon-file-excel" circle ></el-button>
				<el-button  type="primary" plain icon="el-icon-Delete" circle />
				<scFilterBar filterName="filterName" :options="options" @filterChange="change">
					<template #default="{ filterLength, openFilter }">
						<el-badge :value="filterLength" type="danger" :hidden="filterLength <= 0">
							<el-button type="primary" plain icon="el-icon-filter" @click="openFilter" circle></el-button>
						</el-badge>
					</template>
				</scFilterBar>
			</div>
		</el-header>
		<el-main class="nopadding">
			<sc-Table
				ref="table"
				:stripe="true"
				:hidePagination="false"
				:hideDo="false"
				:params="params"
				stripe
				remoteSort
				remoteFilter
				row-key="id"
				:apiObj="apiObj"
				:data="tableData"
				:column="tableColumns">
				<el-table-column
					type="index"
					label="序号"
					width="80"
					align="center"
				/>
			</sc-Table>
		</el-main>
	</el-container>
</template>

<script setup>
import { ref, getCurrentInstance  } from 'vue'
import data from './json/data.json'
import columns from './json/columns.json'
import options from './json/filter.js';
import searchCmp from './search2.vue'
const { proxy: { $API } } = getCurrentInstance()
// 表格数据
const tableData = ref(data)
// 表格列配置
const tableColumns = ref(columns)

const apiObj = ref($API.simple.list)

const params = ref({});


const config = ref({
	labelWidth: '100',
	labelPosition: 'right',
	size: 'default',
	emptySize: 2,
	emptySpan: 6,
	mode:'search',
	span: 6,
	formItems: [
		{
			label: '表格选择器',
			name: 'tableselect',
			value: {},
			component: 'tableselect',
			options: {
				apiObj: $API.simple.list,
				column: columns,
				props: {
					label: 'user',
					value: 'id',
					keyword: 'keyword'
				}
			}
		},
		{
			label: '姓名',
			name: 'name',
			value: '',
			span:6,
			component: 'input',
			attrs: {
				placeholder: '请输入姓名'
			},
		},
		{
			label: '真名',
			name: 'realName',
			value: '',
			span:6,
			component: 'input',
			attrs: {
				placeholder: '请输入真名'
			},
		},
		{
			label: '假名',
			name: '_name',
			value: '',
			span:6,
			component: 'input',
			attrs: {
				placeholder: '请输入假名'
			},
		},
		{
			label: '日期/时间',
			name: 'date',
			value: '',
			span:6,
			component: 'date-picker',
			attrs: {
				type: 'datetime',
				valueFormat: 'YYYY-MM-DD HH:mm:ss'
			},
		}
	]
})


const onSearch = ( ret) => {
	console.log(ret)
}

</script>

<style>

</style>
